package com.zr.daishenpi.service.impl;

import com.zr.daishenpi.mapper.PaydivideMapper;
import com.zr.daishenpi.pojo.Paydivide;
import com.zr.daishenpi.pojo.PaydivideSelectVo;
import com.zr.daishenpi.service.PaydivideService;
import com.zr.lendinglist.model.LendingList;
import com.zr.util.AllRecords;
import com.zr.util.ResultVO;
import com.zr.util.ResultVOBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2019/7/9.
 */
@Service
public class PaydivideServiceImpl implements PaydivideService {

    @Autowired
    private PaydivideMapper paydivideMapper;


    /**
     * 分页查询
     * @param paydivideSelectVo
     * @return
     */
    @Override
    public ResultVO<AllRecords> queryPage(PaydivideSelectVo paydivideSelectVo) {
        //查询数据
        List<Paydivide> paydivideList = paydivideMapper.queryPage(paydivideSelectVo);
        //查询数量
        int count =  paydivideMapper.queryCount(paydivideSelectVo);
        //把当前页、每页大小、总页数、总条数、数据统一放入到AllRecords返回
        AllRecords allRecords = new AllRecords();
        allRecords.setPageIndex(paydivideSelectVo.getPageIndex());
        allRecords.setPageSize(paydivideSelectVo.getPageSize());
        allRecords.setTotalNumber(count);
        allRecords.resetTotalNumber(count);
        allRecords.setDataList(paydivideList);
        return ResultVOBuilder.success(allRecords);
    }

}
